﻿using Domain;
using Microsoft.EntityFrameworkCore;

namespace Infratructure
{
    /// <summary>
    /// 上下文链接
    /// </summary>
    public class MyDBcontext : DbContext
    {
        public MyDBcontext(DbContextOptions options) : base(options)
        {
        }
        /// <summary>
        /// 用户模块
        /// </summary>
        public DbSet<UserModel> UserModel { get; set; }
        /// <summary>
        /// 角色模块
        /// </summary>
        public DbSet<RoleModel> RoleModel { get; set; }
        /// <summary>
        /// 商品模块
        /// </summary>
        public DbSet<GoodsModel> GoodsModel { get; set; }
        /// <summary>
        /// 养殖模块
        /// </summary>
        public DbSet<BreedModel> BreedModel { get; set; }
        /// <summary>
        /// 屠宰模块
        /// </summary>
        public DbSet<KillModel> KillModel { get; set; }
        /// <summary>
        /// 深加工模块
        /// </summary>
        public  DbSet<FinishStepModel> FinishStepModel { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<GoodsModel>().HasQueryFilter(x => x.IsDel == false);  //过滤商品软删除
            modelBuilder.Entity<KillModel>().HasQueryFilter(x => x.IsDel == false);
            modelBuilder.Entity<BreedModel>().HasQueryFilter(x => x.IsDel == false);
            modelBuilder.Entity<FinishStepModel>().HasQueryFilter(x => x.IsDel == false);
        }

    }
}
